package com.itboye.sunsun.adapter;

import java.util.List;

import com.itboye.sunsun.R;
import com.itboye.sunsun.address.ForumPostModel;
import com.itboye.sunsun.beans.CustomBean;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;


public class ForumPostAdaper extends  BaseAdapter {



	private Context context;
	private List<ForumPostModel> list;
	
	

	public ForumPostAdaper(Context context, List<ForumPostModel> list) {
		this.context = context;
		this.list = list;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public int getItemViewType(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public int getViewTypeCount() {
		// TODO Auto-generated method stub
		return 3;
	}

	

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		
		HandView mHandView;
		if(convertView==null){
			mHandView=new HandView();
			convertView = LayoutInflater.from(context).inflate(
					R.layout.forum_post_item_andpost, null);
			mHandView.name=(TextView) convertView.findViewById(R.id.post_name);
			mHandView.landlord=(ImageView) convertView.findViewById(R.id.img_post_hed);
			mHandView.post_time=(TextView) convertView.findViewById(R.id.post_time);
			mHandView.contenxt=(TextView) convertView.findViewById(R.id.post_content);
			mHandView.img_reply=(ImageView) convertView.findViewById(R.id.img_post_leit);
			mHandView.img_zan=(ImageView) convertView.findViewById(R.id.img_post_centet);
			mHandView.lei=(ImageView) convertView.findViewById(R.id.img_post_gheit);
			mHandView.centent=(ImageView) convertView.findViewById(R.id.post_item_ping);
			mHandView.ght=(ImageView) convertView.findViewById(R.id.post_item_zan);
			convertView.setTag(mHandView);
			
		}else {
			mHandView=(HandView) convertView.getTag();
		}
		
		//fuzhi
		mHandView.name.setText(list.get(position)
				.getName());
		// 是否是楼主
		/*mHandView.text_item_convertion_lou.setText(mlist.get(position)
				.getContxt());*/
		// 时间
		mHandView.landlord.setImageBitmap(list.get(position).getLandlord());
		// 评论内容
		mHandView.post_time.setText(list.get(position).getPost_time());
		mHandView.post_time.setText(list.get(position).getPost_time());
		mHandView.contenxt.setText(list.get(position)
				.getContenxt());
//		mHandView.img_reply.setImageBitmap(list.get(position).getImg_reply());
		
		return convertView;
	}
	public class HandView{
		TextView name,post_time,contenxt;
		ImageView img_reply,img_zan,lei,centent,ght,landlord;

	}
}
